Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fix for incorrectly marked collected reference on X86 #3035

Closed
wants to merge 1 commit into from

Conversation

0dvictor
Copy link
Contributor

@0dvictor 0dvictor commented Oct 5, 2018

The result register of TR::aiadd/TR::aladd was incorrectly marked as a
collected reference, when the aiadd/aladd node is not internal pointer.
As a result, an invalid GC map entry may be introduced and causes GC assertions.
The result of TR::aiadd/TR::aladd can never be a collected reference, fixing it.

Signed-off-by: Victor Ding [email protected]

@liqunl
Copy link
Contributor

liqunl commented Oct 5, 2018

The commit message is worrying me and seems wrong. The result of aiadd and aladd can be a collected reference if they're internal pointer. There is an API to compute the collectedness of a data. It's OMR::Node::computeIsCollectedReference. But this API might not work after lower tree since we do a lot of a2l.

@0dvictor
Copy link
Contributor Author

0dvictor commented Oct 5, 2018

@liqunl Could you give some examples when the result of TR::aiadd/TR::aladd should return a collected reference?
If the address node is a collected reference, the result of [address+offset] cannot be another collected reference; if the address node is not a collected reference, how can we possibly know the result is a collected reference?

@liqunl
Copy link
Contributor

liqunl commented Oct 5, 2018

I was confused because there are similar concepts on symbol and on node, they are slightly different than the concept in codegen. On Node and Symbol, collected reference and internal pointer are both considered to be collected, but there is addition flag for internal pointer which is used by codegen to create gc map for it (when it also has a pinning array) but not to treat them as the real collected reference.

I agree that aiadd/aladd can't be collected refenrence regardless of whether they're internal pointers. I have no issue with the commit message now.

@andrewcraik
Copy link
Contributor

@vijaysun-omr could you review? I think this is popping up a fair number of failures in recent builds.

@vijaysun-omr vijaysun-omr changed the title Fix for incorrected marked collected reference X86 Fix for incorrectly marked collected reference X86 Oct 5, 2018
@vijaysun-omr vijaysun-omr changed the title Fix for incorrectly marked collected reference X86 Fix for incorrectly marked collected reference on X86 Oct 5, 2018
else if (comp->generateArraylets() && root->getOpCodeValue() == TR::aiadd)
// arraylets: aiadd is technically internal pointer into spine object, but isn't marked as internal pointer
tempReg = _cg->allocateRegister();
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume this allocateCollectedReferenceRegister section of code is the one that was causing problems ?
Could you please elaborate on the actual problem that you are fixing ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result register (tempReg here) was incorrectly marked as a collected reference, when the aiadd/aladd node is not internal pointer. As a result, an invalid GC map entry may be introduced and causes GC assertions.
I cannot think of any valid reasons that this result could be collected; therefore, all branches are now to allocate a "non-collected" register instead of "collected" ones.

Copy link
Contributor

@vijaysun-omr vijaysun-omr Oct 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we would have used an uncollected register if the isInternalPointer flag would have been "true" on this aiadd/aladd. I expect this node flag would be set on all aiadd/aladd in Java but I guess you saw some case where that flag was not set (?) If so, how did such a node originate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is from Value Propagation where a TR::arraycopy gets generated. The source and destination children are TR::aladd.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these aladds created by arraycopy generation in value propagation don't have the internal pointer flag set, then we should consider setting the flag and see if that fixes the failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But either way aladd shouldn't return a collected reference. It doesn't make sense to create a collected reference from [address+offset].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but it's preferable to fix a bug in common code if we can so that each platform does'nt have to make changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. @liqunl kindly agreed to investigate why root->isInternalPointer() answered no as a separate issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like VP arraycopy transformation creates an aiadd/aladd without setting the flag. I'm trying to find where the node is created.

@vijaysun-omr
Copy link
Contributor

It seems the title of the PR may have been changed based on @liqunl earlier comment but the PR description and the commit message are still using the words that she requested a change to.

Can you please change the commit message and be more descriptive in terms of why this change was needed ? i.e. under what situation were we using a collected reference register for an aiadd/aladd ?

@vijaysun-omr
Copy link
Contributor

@genie-omr build xlinux win

@liqunl
Copy link
Contributor

liqunl commented Oct 5, 2018

It seems the title of the PR may have been changed based on @liqunl earlier comment but the PR description and the commit message are still using the words that she requested a change to.

I have no problem with the wording now, but I agree that we need a more descriptive commit message.

@0dvictor
Copy link
Contributor Author

0dvictor commented Oct 5, 2018

Commit messages have been updated. Sanity tests may need be restarted.

@liqunl
Copy link
Contributor

liqunl commented Oct 9, 2018

Created #3040 to set internal pointer node flags in VP.

@andrewcraik
Copy link
Contributor

@vijaysun-omr and @0dvictor I'm not sure if this is the fix we want in general. #3046 was just merged to fix the missing flag. In general we seem to have a principle of offsets to a collected reference result in a collected reference unless the result is explicitly marked as an internal pointer not to be reported to the GC. removing the functionality to allow collected reference to be generated from collected references via explicit offsets not marked internalPointer because Java doesn't use the feature doesn't seem to be quite the right solution. Now there may be another good reason for removing it, but VP failing to set a flag that is required by current convention doesn't seem like a problem the codegen should be trying to fix as alluded to earlier.

@0dvictor
Copy link
Contributor Author

I don't this this PR is needed to fix #3040 either. This is a generic feature fix, while #3046 is the fix for root cause of #3040.

@0dvictor
Copy link
Contributor Author

0dvictor commented Oct 12, 2018

@andrewcraik raised a good point. I think our different points of views came from different understanding of the semantics of TR::aiadd/TR:aladd. I suggest to wait for #2569 before making decision whether this changeset should be merged.

Marking this PR as WIP for now.

@0dvictor 0dvictor changed the title Fix for incorrectly marked collected reference on X86 WIP: Fix for incorrectly marked collected reference on X86 Oct 12, 2018
@vijaysun-omr vijaysun-omr self-assigned this Oct 25, 2018
@0dvictor 0dvictor requested a review from mstoodle as a code owner December 3, 2018 23:01
@Leonardo2718
Copy link
Contributor

@0dvictor any updates on this?

@0dvictor
Copy link
Contributor Author

Not yet. I don't think we can progress this further until the semantics of TR::iadd/TR::ladd is clear.

The result register of TR::aiadd/TR::aladd was incorrectly marked as a
collected reference, when the aiadd/aladd node is not internal pointer.
As a result, an invalid GC map entry may be introduced and causes GC assertions.
The result of TR::aiadd/TR::aladd can never be a collected reference, fixing it.

Signed-off-by: Victor Ding <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants